home *** CD-ROM | disk | FTP | other *** search
/ Shocking The Web CD-ROM / SHOCK_CD.ISO / mac / Chapter Tutorials / CaseStudies / ch12.ISN / input.dir / 00050.ls < prev    next >
Encoding:
Text File  |  1996-12-04  |  5.9 KB  |  191 lines

  1. global gMyMessage, gMessageLength, gIterCount, gCharToNumList, gCastNumList, gStopPoint, gStopFlag, gHowLongHold, gBlinkFlag, gBlinkOffset, gNumCharsToBlink, gStopOffset, gWindowName, gMyWindow, gCharColorList, gURLName
  2.  
  3. on startMovie
  4.   puppetTempo(10)
  5.   set gWindowName to "LEDMIAW.DIR"
  6.   set gStopFlag to 0
  7.   set gStopPoint to 36
  8.   set gHowLongHold to 5
  9.   set gURLName to " "
  10.   beginMyMovie()
  11. end
  12.  
  13. on stopMovie
  14.   finishMovie()
  15. end
  16.  
  17. on beginMyMovie
  18.   if objectp(gMyWindow) then
  19.     forget(gMyWindow)
  20.   end if
  21.   set horzorigin to the stageLeft + ((the stageRight - 400) / 2)
  22.   set vertorigin to the stageTop + 62
  23.   set gMyWindowRect to rect(horzorigin, vertorigin, horzorigin + 400, vertorigin + 14)
  24.   set gMyWindow to window gWindowName
  25.   set the rect of gMyWindow to gMyWindowRect
  26.   set the fileName of gMyWindow to gWindowName
  27.   set the titleVisible of gMyWindow to 0
  28.   set the windowType of gMyWindow to 2
  29.   open(gMyWindow)
  30. end
  31.  
  32. on finishMovie
  33.   if objectp(gMyWindow) then
  34.     forget(gMyWindow)
  35.   end if
  36. end
  37.  
  38. on writeMessage
  39.   if gIterCount >= (count(gCharToNumList) - 35) then
  40.     set gIterCount to 0
  41.   else
  42.     repeat with x = 47 down to 12
  43.       set myNum to getAt(gCharToNumList, x - 11 + gIterCount)
  44.       set the foreColor of sprite x to 225
  45.       set the castNum of sprite x to myNum
  46.     end repeat
  47.     updateStage()
  48.     set gIterCount to gIterCount + 1
  49.   end if
  50. end
  51.  
  52. on writeNStop
  53.   if gIterCount >= (count(gCharToNumList) - 35) then
  54.     set gIterCount to 0
  55.   else
  56.     if gIterCount = gStopPoint then
  57.       if gBlinkFlag then
  58.         go("HoldNBlink")
  59.       else
  60.         go("Hold")
  61.       end if
  62.     else
  63.       repeat with x = 47 down to 12
  64.         set myNum to getAt(gCharToNumList, x - 11 + gIterCount)
  65.         set the foreColor of sprite x to 225
  66.         set the castNum of sprite x to myNum
  67.       end repeat
  68.       updateStage()
  69.       set gIterCount to gIterCount + 1
  70.     end if
  71.   end if
  72. end
  73.  
  74. on saveText
  75.   set gMyMessage to the text of field "Message"
  76.   set gCharColorList to [225, 225, 225, 225, 225, 225, 225, 225, 225, 225, 225, 225, 225, 225, 225, 225, 225, 225, 225, 225, 225, 225, 225, 225, 225, 225, 225, 225, 225, 225, 225, 225, 225, 225, 225]
  77.   repeat with i = 1 to the number of chars in gMyMessage
  78.     set theColor to the foreColor of char i of field "Message"
  79.     if theColor = 255 then
  80.       set theColor to 225
  81.     end if
  82.     append(gCharColorList, theColor)
  83.   end repeat
  84.   repeat with i = 1 to 35
  85.     append(gCharColorList, 255)
  86.   end repeat
  87.   set gMyMessage to "                                   " & gMyMessage & "                                   "
  88.   set gCharToNumList to []
  89.   cursor(4)
  90.   repeat with y = 1 to the number of chars in gMyMessage
  91.     set myCharToNum to the number of member char y of gMyMessage
  92.     add(gCharToNumList, myCharToNum)
  93.   end repeat
  94.   set whatToWrite to string(gStopPoint) & RETURN & string(gHowLongHold) & RETURN & string(gStopFlag) & RETURN & string(gBlinkFlag) & RETURN & string(gBlinkOffset) & RETURN & string(gNumCharsToBlink) & RETURN & string(gStopOffset) & RETURN & string(gCharToNumList) & RETURN & string(gCharColorList) & RETURN & string(gURLName) & RETURN
  95.   set myTextFile to fileio(mnew, "?write", "LEDText.txt")
  96.   if not objectp(myTextFile) then
  97.     set theProblem to string(myTextFile)
  98.     checkError(theProblem)
  99.     cursor(-1)
  100.     exit
  101.   else
  102.     myTextFile(mWriteString, whatToWrite)
  103.     myTextFile(mdispose)
  104.     cursor(-1)
  105.   end if
  106. end
  107.  
  108. on readLEDText
  109.   if objectp(myLEDText) then
  110.     myLEDText(mdispose)
  111.   end if
  112.   set myLEDText to fileio(mnew, "?read", "TEXT")
  113.   if not objectp(myLEDText) then
  114.     set theProblem to string(myLEDText)
  115.     checkError(theProblem)
  116.     exit
  117.   else
  118.     set newLEDValues to myLEDText(mReadFile)
  119.     myLEDText(mdispose)
  120.     if not listp(value(line 8 of newLEDValues)) then
  121.       alert("Not a valid LED Player text file!")
  122.     else
  123.       set gStopPoint to value(line 1 of newLEDValues)
  124.       set gHowLongHold to value(line 2 of newLEDValues)
  125.       set gStopFlag to value(line 3 of newLEDValues)
  126.       set gBlinkFlag to value(line 4 of newLEDValues)
  127.       set gBlinkOffset to value(line 5 of newLEDValues)
  128.       set gNumCharsToBlink to value(line 6 of newLEDValues)
  129.       set gStopOffset to value(line 7 of newLEDValues)
  130.       set gCharToNumList to value(line 8 of newLEDValues)
  131.     end if
  132.     if objectp(myLEDText) then
  133.       myLEDText(mdispose)
  134.     end if
  135.   end if
  136. end
  137.  
  138. on checkError theProblem
  139.   if theProblem = -33 then
  140.     alert("File directory full." & RETURN & RETURN & "Error: " & string(theProblem))
  141.     exit
  142.   end if
  143.   if theProblem = -34 then
  144.     alert("This disk is completely full! Please delete some files and make some room." & RETURN & RETURN & "Error: " & string(theProblem))
  145.     exit
  146.   end if
  147.   if theProblem = -35 then
  148.     alert("Volume not found." & RETURN & RETURN & "Error: " & string(theProblem))
  149.     exit
  150.   end if
  151.   if theProblem = -36 then
  152.     alert("Disk error encountered." & RETURN & RETURN & "Error: " & string(theProblem))
  153.     exit
  154.   end if
  155.   if theProblem = -37 then
  156.     alert("The file name you've chosen is no good or you've used an invalid character. Please check then save again." & RETURN & RETURN & "Error: " & string(theProblem))
  157.     exit
  158.   end if
  159.   if theProblem = -38 then
  160.     alert("File not open." & RETURN & RETURN & "Error: " & string(theProblem))
  161.     exit
  162.   end if
  163.   if theProblem = -42 then
  164.     alert("You've got too many files open!." & RETURN & RETURN & "Error: " & string(theProblem))
  165.     exit
  166.   end if
  167.   if theProblem = -43 then
  168.     beep()
  169.     exit
  170.   end if
  171.   if theProblem = -56 then
  172.     alert("No such drive." & RETURN & RETURN & "Error: " & string(theProblem))
  173.     exit
  174.   end if
  175.   if theProblem = -65 then
  176.     alert("No disk in drive." & RETURN & RETURN & "Error: " & string(theProblem))
  177.     exit
  178.   end if
  179.   if theProblem = -120 then
  180.     alert("Directory not found." & RETURN & RETURN & "Error: " & string(theProblem))
  181.     exit
  182.   end if
  183. end
  184.  
  185. on makeList
  186.   set gCastNumList to [:]
  187.   repeat with x = 1 to 48
  188.     addProp(gCastNumList, the name of cast x, x)
  189.   end repeat
  190. end
  191.